package jsc.graph;

import java.awt.BorderLayout;
import java.awt.Container;
import java.util.HashSet;

import javax.swing.DefaultListModel;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;

import jsc.acid.Word;

/**
 * This class display one word and its list of potential rectification
 * 
 * @author Alec Ermis, Maxime Rihouey
 *
 */

public class ComponentWrongWords extends Container{

	private JLabel lblWord;
	private JList listAlter;
	private JScrollPane scroller;

	// constructors
	public ComponentWrongWords(Word word, HashSet<String> alternatives){
		this.setSize(200, 200);
		initialize(word, alternatives);
	}

	// methods
	public void initialize(Word word, HashSet<String> alternatives){

		this.setLayout(new BorderLayout());
		this.lblWord = new JLabel(word.getWord());

		this.add(lblWord, BorderLayout.NORTH);
		DefaultListModel listModel = new DefaultListModel();
		for(String alternative: alternatives){
			listModel.addElement(alternative);
		}
		listAlter = new JList(listModel);
		scroller = new JScrollPane(listAlter);
		this.add(scroller, BorderLayout.CENTER);

	}

}
